package com.aaa.multithreading.demo04;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description:这个人取钱
 * @date 2022/10/31
 */
public class PeopleTake implements Runnable{
    private Card card;

    public PeopleTake(Card card) {
        this.card = card;
    }

    @Override
    public void run() {
        for (int i = 0; i <10; i++) {
            if(card.getBalance()>=1000){
                card.setBalance(card.getBalance()-1000);
                System.out.println(Thread.currentThread().getName()+"从卡中取出1000元，卡中余额剩余:"+card.getBalance());
            }else {
                System.out.println("卡里余额不足请充值:");
                i--;
            }
        }
    }
}
